package Proyecto2;

import java.awt.BorderLayout;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Logica extends javax.swing.JFrame {
	protected Nivel MiNivel;
	protected ImagePanel jPanelNivel;
	protected NaveJugador MiNave;
	private JLabel jLabelPuntaje;
	protected JPanel jPanelFondo;
	protected JLabel jLabelPerdi;
	private JLabel jLabelCorazon;
	protected JLabel jLabelPuntos;
	protected JPanel PanelPuntos;
	private JToolBar jToolBarTop;
	protected MenteTeclado menteTeclado;
	

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SplashScreen splash = new SplashScreen(4000);
		splash.showSplash();
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				Logica inst = new Logica();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	public Logica() {
		super();
		initGUI();
		initGame();
		//initAudio();
	}
	


	private void initGame() {	
		
		menteTeclado = new MenteTeclado(MiNave, this);
		this.addKeyListener(menteTeclado);
		MiNivel.setJuego(this);
		MiNivel.elegirNavePcipal(MiNave);
		MiNivel.Juego();
		
	}

	
	private void initGUI() {
		try {
			this.setLocationByPlatform(true);
			setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			getContentPane().setBackground(new java.awt.Color(173,216,230));
			this.setResizable(false);

			ImageIcon img=new ImageIcon(getClass().getClassLoader().getResource("Imagenes/submarino-2-coral-arrecife.jpg"));
			jPanelNivel = new ImagePanel(img.getImage());
			getContentPane().add(jPanelNivel, BorderLayout.CENTER);
			jPanelNivel.setLayout(null);
			jPanelNivel.setOpaque(false);
			jPanelNivel.setBackground(new java.awt.Color(131,186,204));
			jPanelNivel.setVisible(true);
			
			{
				MiNivel = new Nivel();
				MiNave = new Submarino(MiNivel);
				jPanelNivel.add(MiNave);
				MiNave.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/submarino1.png")));
				MiNave.setBounds(0, 0,MiNave.getIcon().getIconWidth(), MiNave.getIcon().getIconHeight());

				jToolBarTop = new JToolBar();
				getContentPane().add(jToolBarTop, BorderLayout.NORTH);
				jToolBarTop.setFloatable(false);
				jToolBarTop.setBackground(new java.awt.Color(131,186,204));
			}
			{
				PanelPuntos = new JPanel();
				jPanelNivel.add(PanelPuntos);
				PanelPuntos.setBounds(-1, 0, 595, 38);
				PanelPuntos.setLayout(null);
				PanelPuntos.setBackground(new java.awt.Color(254,220,203));
				{
					jLabelPuntaje = new JLabel();
					PanelPuntos.add(jLabelPuntaje);
					jLabelPuntaje.setText("Score:");
					jLabelPuntaje.setBounds(8, 1, 114, 39);
					jLabelPuntaje.setFont(new java.awt.Font("Segoe UI",1,20));
					jLabelPuntaje.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/monedita.gif")));
					jLabelPuntaje.setForeground(new java.awt.Color(255,0,0));
				}
				{
					jLabelPuntos = new JLabel();
					PanelPuntos.add(jLabelPuntos);
					jLabelPuntos.setText("0000");
					jLabelPuntos.setBounds(99, 1, 55, 39);
					jLabelPuntos.setFont(new java.awt.Font("Segoe UI",1,20));
					jLabelPuntos.setForeground(new java.awt.Color(255,0,0));
					jLabelPuntos.setBackground(new java.awt.Color(255,255,125));
				}
				{
					jLabelCorazon = new JLabel();
					PanelPuntos.add(jLabelCorazon);
					jLabelCorazon.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/CorazonBurbuja3.png")));
					jLabelCorazon.setBounds(477, 0, 118, 38);
				}
			}
			{
				jLabelPerdi = new JLabel();
				jPanelNivel.add(jLabelPerdi);
				jLabelPerdi.setText("Game Over");
				jLabelPerdi.setBounds(145, 307, 286, 75);
				jLabelPerdi.setFont(new java.awt.Font("Britannic Bold",1,36));
				jLabelPerdi.setBackground(new java.awt.Color(255,0,0));
				jLabelPerdi.setForeground(new java.awt.Color(255,0,0));
				jLabelPerdi.setVisible(false);
				jLabelPerdi.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/gameover (2).gif")));
			}
			{

			}

			pack();
			this.setSize(600, 700);
		}
		catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
}